package org.ddd.book.book;

import cn.hutool.core.collection.CollectionUtil;
import lombok.extern.slf4j.Slf4j;
import org.ddd.book.domain.book.entity.BookEntity;
import org.ddd.book.domain.book.repository.IBookRepository;
import org.ddd.book.domain.factoty.RepositoryFactory;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class BookService {

    public void removeBookshelfAllBook(Long bookshelfId) {
        List<BookEntity> bookList = RepositoryFactory.get(IBookRepository.class).bookshelfBookList(bookshelfId);
        if (CollectionUtil.isEmpty(bookList)) {
            return;
        }
        bookList.forEach(BookEntity::remove);
    }

}
